/*
 * LocalSol.h
 *
 *  Created on: Jun 2, 2012
 *      Author: hugo
 */

#ifndef LOCALSOL_H_
#define LOCALSOL_H_
#include <vector>
#include "Vertex.h"
#include "Instance.h"
#include "Solution.h"
using namespace std;

class LocalSol {
public:
	LocalSol(Instance*);
	LocalSol(Instance*,Solution*);
	virtual ~LocalSol();
	void add_vertex(Vertex*);
	void add_vertex(int);
	void smart_add_vertex(int);
	float tmp_add_vertex(int);
	void remove_vertex(Vertex*);
	void remove_vertex(int);
	void compute();
	float get_cost();
	Solution* get_solution();
	bool has_vertex(Vertex*);
	bool has_vertex(int);
	bool has_edge(Edge*);
	bool has_edge(int);
	bool has_connection(int);
	Edge* get_connection(int);
	LocalSol* copy();
	LocalSol* copy_nodes();
	void print();
	float prim();
	float prim(bool tmp);
	float prim_prize();
	float kruskal();
	float kruskal(bool tmp);
private:
	Instance *instance;
	int *nodes;
	int *edges;
	int *tmp_edges;
	float tmp_prim_cost;
	bool changed;
	float cost;
	float prim_cost;
	float kruskal_prize;
	float prone();
	void pre_prone();
	int* prim(int *visited, int init_i, float *p_cost, float *prize);
};

#endif /* LOCALSOL_H_ */
